<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>

    <xsl:template match="/">
        <html>
            <head>
                <title>orderXSLT1.xsl</title>
            </head>
            <body>

                <br/>
                <xsl:apply-templates select="/Opdracht/relaties">
                    <xsl:sort select="/Opdracht/relaties/relatie/datum-begin"/>
                </xsl:apply-templates>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="relaties">

        <xsl:apply-templates select="relatie"/>
        
    </xsl:template>

    <xsl:template match="relatie">
        <xsl:variable name="persnr">
            <xsl:value-of select="@pers1nr"/>
        </xsl:variable>
        <b>Partner1: </b>
        <!--<xsl:value-of select="$persnr"/>
        <br/>-->
        <xsl:apply-templates select="/Opdracht/personen/persoon[@id=$persnr]"/>

        <xsl:variable name="pers2nr">
            <xsl:value-of select="@pers2nr"/>
        </xsl:variable>
        <b>Partner2: </b>
        <xsl:apply-templates select="/Opdracht/personen/persoon[@id=$pers2nr]"/>
        <!--<xsl:value-of select="$pers2nr"/>-->
       <!-- <hr/> -->
        Relatie:
        <xsl:value-of select="type"/>
        <br/>
        <xsl:if test="naambehoud!=''">
            <b>Naamsbehoud:
                <xsl:value-of select="naambehoud"/>
            </b>
            <br/>
        </xsl:if>
        Datum verandering:
        <xsl:variable name="datum-begin">
            <xsl:value-of select="datum-begin"/>
        </xsl:variable>
        <xsl:call-template name="FormatDate">
            <xsl:with-param name="DateTime" select="$datum-begin"/>
        </xsl:call-template>
        <hr/>
    </xsl:template>

    <xsl:template match="persoon">
        <xsl:variable name="id">
            <xsl:value-of select="@id"/>
        </xsl:variable>
        <xsl:value-of select="voornaam"/>
        <br/>
        <xsl:if test="naambehoud">
            <xsl:variable name="naambehoud">
                <xsl:value-of select="@naambehoud"/>
                <xsl:apply-templates select="/Opdracht/families/familie[$id=$id]"/>
            </xsl:variable>
            <xsl:value-of select="naambehoud"/>
        </xsl:if>
        Geboren:
        <xsl:variable name="geboortedatum">
            <xsl:value-of select="geboortedatum"/>
        </xsl:variable>
        <xsl:call-template name="FormatDate">
            <xsl:with-param name="DateTime" select="$geboortedatum"/>
        </xsl:call-template>
        Geslacht:
        <xsl:value-of select="geslacht"/>
        <br/>
    </xsl:template>
    <xsl:template match="familie">
        <xsl:variable name="persnr">
            <xsl:value-of select="persnr"/>
        </xsl:variable>
        hhoi
    </xsl:template>

    <xsl:template name="FormatDate">
        <xsl:param name="DateTime" />
    <!-- 2011-01-26 -->

        <xsl:variable name="jaar">
            <xsl:value-of select="substring($DateTime,1,4)" />
        </xsl:variable>

     <!--jaar=<xsl:value-of select="$jaar"/><br/>-->
        <xsl:variable name="maand">
            <xsl:value-of select="substring($DateTime,6,2)" />
        </xsl:variable>
     <!--maand=<xsl:value-of select="$maand"/><br/>-->

        <xsl:variable name="dag">
            <xsl:value-of select="substring($DateTime,9,2)" />
        </xsl:variable>
    <!-- dag=<xsl:value-of select="$dag"/><br/>-->

        <xsl:variable name="maandNaam">
            <xsl:choose>
                <xsl:when test="$maand = '01'">Jan</xsl:when>
                <xsl:when test="$maand = '02'">Feb</xsl:when>

                <xsl:when test="$maand = '03'">Maart</xsl:when>
                <xsl:when test="$maand = '04'">April</xsl:when>
                <xsl:when test="$maand = '05'">Mei</xsl:when>
                <xsl:when test="$maand = '06'">Juni</xsl:when>
                <xsl:when test="$maand = '07'">Juli</xsl:when>
                <xsl:when test="$maand = '08'">Augustus</xsl:when>
                <xsl:when test="$maand = '09'">September</xsl:when>
                <xsl:when test="$maand = '10'">Oktober</xsl:when>
                <xsl:when test="$maand = '11'">November</xsl:when>
                <xsl:when test="$maand = '12'">December</xsl:when>

            </xsl:choose>
        </xsl:variable>
<!--maandNaam=<xsl:value-of select="$maandNaam"/><br/>-->
        <xsl:value-of select="$dag"/>-
        <xsl:value-of select="$maandNaam"/>-
        <xsl:value-of select="$jaar"/>
        <br/>

    </xsl:template>



</xsl:stylesheet>